
# 卡普雷尔黑洞
aa = 8990
while len(set(str(aa))) != 1 and aa !=6174:
    a = list(str(aa))
    b = int(''.join(sorted(a)))
    c = int(''.join(sorted(a, reverse=True)))
    aa = c-b
    print(aa)


